package com.runtime.hongyunuser.controller;

import com.runtime.hongyunuser.bean.Carousels;
import com.runtime.hongyunuser.bean.Code;
import com.runtime.hongyunuser.bean.Result;
import com.runtime.hongyunuser.service.CategoriesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("category")
public class CategoriesController {

    @Autowired
    private CategoriesService categoriesService;

    @GetMapping("/catalog")
    public Result getCatalogData() {
        try {
            return new Result(20041, categoriesService.getCatalogData(), "获取分类目录成功");
        } catch (Exception e) {
            return new Result(500, null, "获取分类目录失败: " + e.getMessage());
        }
    }

    @GetMapping("carousels")
    public List<Carousels> getAllActiveCarousels() {
        return categoriesService.getAllActiveCarousels();
    }

}
